home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / a-comlin.adb < prev    next >
Text File  |  1996-01-30  |  3KB  |  72 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --                     A D A . C O M M A N D _ L I N E                      --
  6. --                                                                          --
  7. --                                 B o d y                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.5 $                              --
  10. --                                                                          --
  11. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  12. --                                                                          --
  13. -- The GNAT library is free software; you can redistribute it and/or modify --
  14. -- it under terms of the GNU Library General Public License as published by --
  15. -- the Free Software  Foundation; either version 2, or (at your option) any --
  16. -- later version.  The GNAT library is distributed in the hope that it will --
  17. -- be useful, but WITHOUT ANY WARRANTY;  without even  the implied warranty --
  18. -- of MERCHANTABILITY  or  FITNESS FOR  A PARTICULAR PURPOSE.  See the  GNU --
  19. -- Library  General  Public  License for  more  details.  You  should  have --
  20. -- received  a copy of the GNU  Library  General Public License  along with --
  21. -- the GNAT library;  see the file  COPYING.LIB.  If not, write to the Free --
  22. -- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.        --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. with System;
  27. package body Ada.Command_Line is
  28.  
  29.    function Arg_Count return Natural;
  30.    pragma Import (C, Arg_Count, "arg_count");
  31.  
  32.    procedure Fill_Arg (A : System.Address; Arg_Num : Integer);
  33.    pragma Interface (C, Fill_Arg);
  34.  
  35.    function Len_Arg (Arg_Num : Integer) return Integer;
  36.    pragma Interface (C, Len_Arg);
  37.  
  38.    --------------------
  39.    -- Argument_Count --
  40.    --------------------
  41.  
  42.    function Argument_Count return Natural is
  43.    begin
  44.       return Arg_Count - 1;
  45.    end Argument_Count;
  46.  
  47.    --------------
  48.    -- Argument --
  49.    --------------
  50.  
  51.    function Argument (Number : in Positive) return String is
  52.       Arg : aliased String (1 .. Len_Arg (Number));
  53.  
  54.    begin
  55.       Fill_Arg (Arg'Address, Number);
  56.       return Arg;
  57.    end Argument;
  58.  
  59.    ------------------
  60.    -- Command_Name --
  61.    ------------------
  62.  
  63.    function Command_Name return String is
  64.       Arg : aliased String (1 .. Len_Arg (0));
  65.  
  66.    begin
  67.       Fill_Arg (Arg'Address, 0);
  68.       return Arg;
  69.    end Command_Name;
  70.  
  71. end Ada.Command_Line;
  72.